//
//  HBHChouseJobValueCell.m
//  HubeiHotel
//
//  Created by 张露杰 on 18/4/10.
//  Copyright © 2018年 张露杰. All rights reserved.
//

#import "HBHChouseJobValueCell.h"

@implementation HBHChouseJobValueCell
{
    NSArray *_datas;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    //    继承父类
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = 0;
    }
    return self;
}

-(void)loadCellWithData:(NSArray *)datas title:(NSString *)title selectData:(NSDictionary *)selectData
{
    //    重新布局
    for (UIView *view in self.contentView.subviews) {
        [view removeFromSuperview];
    }
    _datas = datas;
    UILabel *label = [TomamaUI createLabel:CGRectMake(15*screenW_6, 0, SCREENW - 30*screenW_6, 15*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:15*screenW_6] textColor:TextBlack text:title];
    label.center = CGPointMake(label.center.x, 23*screenW_6);
    [self.contentView addSubview:label];
    
    for (int i = 0; i < datas.count; i++) {
        UIButton *btn = [TomamaUI createButton:0 Frame:CGRectMake(15*screenW_6 + i%4*89*screenW_6, 46*screenW_6 + i/4*49*screenW_6, 76*screenW_6, 36*screenW_6) targ:self sel:@selector(clickOn:) titleColor:TextBlackGray font:[UIFont systemFontOfSize:13*screenW_6] title:datas[i][@"label"] image:nil backGroundImage:nil];
        btn.layer.masksToBounds = YES;
        btn.layer.cornerRadius = 3*screenW_6;
        btn.layer.borderColor = [UIColor colorWithHexString:@"#dbdbdb"].CGColor;
        btn.layer.borderWidth = 1;
        if ([datas[i][@"id"] isEqualToString:selectData[@"id"]]) {
            btn.layer.borderColor = mainColor.CGColor;
            [btn setTitleColor:mainColor  forState:UIControlStateNormal];
        }
        btn.tag = i;
        [self.contentView addSubview:btn];
    }
    
}

-(void)clickOn:(UIButton *)btn
{
    if (_blcok) {
        _blcok(_datas[btn.tag]);
    }
}

@end
